<template>
  <div class="right-main">
    <div class="tob-bar">
      <el-breadcrumb separator=">">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '/case/residualList' }">残保金</el-breadcrumb-item>
        <el-breadcrumb-item>编辑</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="mainContainer addResidual">
      <!-- 添加残保金表单 -->
      <div class="customform shebaoform">
        <el-form
          :inline="true"
          :model="product"
          :rules="rules"
          label-width="120px"
          label-position="left"
          ref="product"
        >
          <div class="el-form--inline">
            <el-form-item label="参保地" >
              <el-input disabled  v-model="product.addrName"></el-input>
            </el-form-item>
            <el-form-item label="服务公司" >
              <el-input disabled  v-model="product.optrCompName"></el-input>
            </el-form-item>
            <el-form-item label="残保金金额" prop="account">
              <el-input placeholder="请输入" type="number" v-model="product.account"></el-input>
            </el-form-item>
          </div>
        </el-form>
      </div>
      <!-- 添加残保金表单结束 -->
      <div class="page-form-btn">
        <el-button @click="back">取消</el-button>
        <el-button type="primary" @click="save">保存</el-button>
      </div>
    </div>
  </div>
</template>

<script>
  import Http from "../../libs/http.js";
  import CompanySelect from  "../../components/CompanySelect";

  export default {
    name: "editResidual",
    components:{CompanySelect},
    data() {
      return {
        // 公积金表单
        product:{
          optrCompId:'',
          addrId:'',
          account:''
        },
        // 必填项目
        rules: {
          addrId: [
            { required: true, message: "请选择参保地", trigger: "change" }
          ],
          optrCompId: [
            { required: true, message: "请选择服务公司", trigger: "change" }
          ],
          account: [
            { required: true, message: "请输入金额", trigger: "change" }
          ],
        },
        addrs:[],

      };
    },
    created() {
      this.getDetail();
    },
    methods: {
      getDetail(){
        Http.api.get("/case/disableproduct/"+this.$route.query.id).then((r)=>{
          this.product = r.data;
        })
      },
      indexMethod(index) {
        return index + 1;
      },
      // 保存
      save() {
        this.$refs['product'].validate((v)=>{
          if(v){
            Http.api.post('/case/disableproduct',this.product).then(()=>{
              this.$router.push({path:"residualList"})
            })
          }else{
            return false ;
          }
        })
      },
      back(){
        this.$router.go(-1);
      }
    }
  };
</script>
